package com.coocaa.ops.admin.v1.policygroup.convert;

import com.coocaa.ops.admin.v1.policygroup.model.query.PolicyGroupInfoModel;
import com.coocaa.ops.common.core.base.util.PageQueryUtil;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author bijiahao
 * @description
 * @date 2020/3/12 15:58
 */
@UtilityClass
public class PolicyGroupQueryConverter {

    public static Map<String, Object> getQuery(PolicyGroupInfoModel model) {
        if (StringUtils.isNotBlank(model.getModel()) && StringUtils.isNotBlank(model.getChip())) {
            //查询机型机芯
            model.setQueryModelChip(3);
        } else if (StringUtils.isNotBlank(model.getModel()) && StringUtils.isBlank(model.getChip())) {
            //只查询机型
            model.setQueryModelChip(1);
        } else if (StringUtils.isNotBlank(model.getChip()) && StringUtils.isBlank(model.getModel())) {
            //只查询机芯
            model.setQueryModelChip(2);
        }
        Map<String, Object> params = PageQueryUtil.getFilterMap(model);
        return params;
    }
}
